package com.hengxinguotong.hxgtwygsp.ui.propertyService.fee;

import android.content.res.Resources;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ProgressBar;
import android.widget.TextView;

import com.hengxinguotong.hxgtwygsp.R;
import com.hengxinguotong.hxgtwygsp.model.AnnualFeesBean;
import com.hengxinguotong.hxgtwygsp.ui.base.BaseTabFragment;
import com.hengxinguotong.hxgtwygsp.widget.RingView;

import java.util.ArrayList;
import java.util.List;

import javax.inject.Inject;

import butterknife.BindView;

/**
 * 年度收费情况
 * Created by CS-Yong
 * 2019/8/8  16:43
 */
public class AnnualFeesFragment extends BaseTabFragment {

    @BindView(R.id.fees_left)
    ImageView mFeesLeft;
    @BindView(R.id.fees_year)
    TextView mFeesYear;
    @BindView(R.id.fees_right)
    ImageView mFeesRight;
    @BindView(R.id.fees_year_container)
    LinearLayout mFeesYearContainer;
    @BindView(R.id.budget_revenue_money)
    TextView mBudgetRevenueMoney;
    @BindView(R.id.budget_revenue_progress)
    ProgressBar mBudgetRevenueProgress;
    @BindView(R.id.budget_expense_money)
    TextView mBudgetExpenseMoney;
    @BindView(R.id.budget_expense_progress)
    ProgressBar mBudgetExpenseProgress;
    @BindView(R.id.budget_balance_money)
    TextView mBudgetBalanceMoney;
    @BindView(R.id.budget_balance_progress)
    ProgressBar mBudgetBalanceProgress;
    @BindView(R.id.in_ring_view)
    RingView mInRingView;
    @BindView(R.id.rv_in_fees)
    RecyclerView mRvInFees;
    @BindView(R.id.out_ring_view)
    RingView mOutRingView;
    @BindView(R.id.rv_out_fees)
    RecyclerView mRvOutFees;

    private List<AnnualFeesBean> mInList = new ArrayList<>(),
    mOutList = new ArrayList<>();
    private AnnualFeesAdapter  mOutAdapter,mInAdapter;

    @Inject
    public AnnualFeesFragment() {

    }

    @Override
    public int getLayoutResId() {
        return R.layout.fragment_annual_fees;
    }

    @Override
    public void init() {
        mockView();
        mOutAdapter =  new AnnualFeesAdapter(R.layout.item_annual_fees,mOutList,R.drawable.annual_fees_out_bg);
        mRvOutFees.setLayoutManager(new LinearLayoutManager(getContext(), LinearLayoutManager.VERTICAL, false));
        mRvOutFees.setAdapter(mOutAdapter);
        mInAdapter =  new AnnualFeesAdapter(R.layout.item_annual_fees,mInList,R.drawable.annual_fees_in_bg);
        mRvInFees.setLayoutManager(new LinearLayoutManager(getContext(), LinearLayoutManager.VERTICAL, false));
        mRvInFees.setAdapter(mInAdapter);

    }

    private void mockView() {

        mFeesYear.setText(String.format(getString(R.string.budget_year), 2018));

        Resources resources = getResources();
        int[] colors = {
                resources.getColor(R.color.cFE5660)
                ,resources.getColor(R.color.cD1B83B)
                , resources.getColor(R.color.c7250FC)
                ,resources.getColor(R.color.c019FFF)};
        mInRingView.setColors(colors);
        float[] values = {56f, 28f, 13f,3f};
        mInRingView.setValues(values);

        mInList.add(new AnnualFeesBean("管理费收入", "437,547.40","56%"));
        mInList.add(new AnnualFeesBean("停车场收入", "216,608.78","28%"));
        mInList.add(new AnnualFeesBean("水电收入", "104,361.04","13%"));
        mInList.add(new AnnualFeesBean("其他收入", "23,533.31","3%"));


        int[] outColors = {resources.getColor(R.color.cFE5660)
                ,resources.getColor(R.color.cD1B83B)
                ,resources.getColor(R.color.c3CC01A)
                ,resources.getColor(R.color.c019FFF)
                ,resources.getColor(R.color.c3BDABA)
                ,resources.getColor(R.color.c7250FC)
                ,resources.getColor(R.color.cE98500)
                ,resources.getColor(R.color.cE739D8)};
        mOutRingView.setColors(outColors);
        float[] outValues = {13f, 18f, 10f, 12f, 4,22,20,1};
        mOutRingView.setValues(outValues);

        mOutList.add(new AnnualFeesBean("人工费", "189,619.35","13%"));
        mOutList.add(new AnnualFeesBean("公共设施维护维修费用", "274,165.49","18%"));
        mOutList.add(new AnnualFeesBean("保洁费用", "154,382.04","10%"));
        mOutList.add(new AnnualFeesBean("保安费用", "172,143.40","12%"));
        mOutList.add(new AnnualFeesBean("停车场费用", "54,181.82","2%"));
        mOutList.add(new AnnualFeesBean("水电费用", "339,901.75","22%"));
        mOutList.add(new AnnualFeesBean("间接费用", "290,915.16","20%"));
        mOutList.add(new AnnualFeesBean("税金及附加", "4,688.48","1%"));

    }

}
